

/*class A{
    public String name;
    A(String name){
        this.name = name;
    }
    public void eat(){
        System.out.println(name + "正在做什么");
    }
}
class B1 extends A{
    B1(String name){
        super(name);
    }
    public void eat(){
        System.out.println(this.name + "喵喵喵~");
    }
}
class B2 extends A{
    B2(String name){
        super(name);
    }
    public void eat(){
        System.out.println(this.name + "汪汪汪~");
    }
}
public class Test{
    public static void function(A a){
        a.eat();
    }
    public static void main(String[] args){
        function(new B1("小猫"));
    }
}*/
//人类
/*class Human{
    private String name;
    Human(String name){
        setName(name);
    }
    public void action(){
        System.out.println(name + "看到一架钢琴~");
    }
    public void setName(String name){
        this.name = name;
    }
    public String getName(){
        return this.name;
    }
}
//美术生
class Art extends Human{
    Art(String name){
        super(name);
    }
    @Override
    public void action(){
        System.out.println(getName() + "开始绘画钢琴~");
    }
}
//音乐生
class Music extends Human{
    Music(String name){
        super(name);
    }
    public void action(){
        System.out.println(getName() + "开始弹钢琴~");
    }
}
public class Test{
    public static void function(Human human){
        human.action();
    }
    public static void main(String[] args){
        Human human = new Music("音乐生");//这样写便是有些人是音乐生
        if(human instanceof Music) {//保证安全性，向下转型
            Music music = (Music) human;
        };
    }
}*/


/*abstract class Human{
    public abstract void func();
}
class Art extends Human{
    @Override
    public void func(){
        System.out.println("画画~");
    }
}
class Music extends Human{
    @Override
    public void func(){
        System.out.println("唱歌~");
    }
}
public class Test{
    public static void function(Human human){
        human.func();
    }
    public static void main(String[] args){
        //Human human = new Human();//抽象类不能实例化对象
        Human human1 = new Art();
        Human human2 = new Music();
        function(human1);
        function(human2);
    }
}*/
/*

interface Human{
    void action();
}
class Art implements Human{
    @Override
    public void action(){
        System.out.println("画画~");
    }
}
class Music implements Human{
    @Override
    public void action(){
        System.out.println("唱歌~");
    }
}
public class Test{
    public static void function(Human human){
        human.action();
    }
    public static void main(String[] args){
        Human human1 = new Art();
        Human human2 = new Music();
        function(human1);
        function(human2);
    }
}*/

abstract class Animal{
    public String name;
    public int age;
    Animal(String name, int age){
        this.name = name;
        this.age = age;
    }
    public abstract void eat();
}
interface IRun{
    int a = 1;
    void run();
}
interface IFly{
    void fly();
}
class Brid extends Animal implements IRun, IFly{
    Brid(String name, int age){
        super(name,age);
    }
    @Override
    public void eat(){
        System.out.println(name + "正在吃小虫子~");
    }
    @Override
    public void run(){
        System.out.println(name + "正在用两条细细的腿蹦来蹦去~");
    }
    @Override
    public void fly(){
        System.out.println(name + "正在飞翔~");
    }
}
class Dog extends Animal implements IRun{
    Dog(String name, int age){
        super(name, age);
    }
    @Override
    public void eat(){
        System.out.println(name + "正在啃骨头~");
    }
    @Override
    public void run(){
        System.out.println(name + "正在用四条腿跑~");
    }
}
public class Test{
    public static void func1(Animal animal){
        animal.eat();
    }
    public static void func2(IRun run){
        run.run();
    }
    public static void func3(IFly fly){
        fly.fly();
    }
    public static void main(String[]  args){
        func1(new Brid("小鸟",1));
        func1(new Dog("狗子",2));
        func2(new Brid("小鸟",1));
        func2(new Dog("狗子",2));
        func3(new Brid("小鸟",1));
    }
}
